package com.anbinh.doctor;

import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView;
import com.anbinh.doctor.fragment.account.FragmentAccount;
import com.anbinh.doctor.fragment.account.FragmentBangGia;
import com.anbinh.doctor.fragment.account.FragmentImages;
import com.anbinh.doctor.fragment.benhnhan.FragmentAddPatients;
import com.anbinh.doctor.fragment.clinic.FragmentClinicLichhen;
import com.anbinh.doctor.fragment.clinic.FragmentClinicMessages;
import com.anbinh.doctor.fragment.clinic.FragmentClinicResultSearch;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicAddBieuHien;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicAddFamilyMedicalHistory;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicAddListMedicalHistory;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicAddNote;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicAddPatients;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicBieuhien;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicFamilyMedicalHistory;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicImagePagerPatients;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicImagesPatients;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicListAppoitMent;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicListMedicalHistory;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicListNote;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicListPatients;
import com.anbinh.doctor.fragment.clinic.benhnhan.FragmentClinicPatientDetailt;
import com.anbinh.doctor.fragment.lichhen.FragmentBookAppointment;
import com.anbinh.doctor.utils.IRcallBak;
import com.anbinh.doctor.utils.Utils;

public class PatientActivity extends SherlockFragmentActivity implements
		IRcallBak, SearchView.OnQueryTextListener,
		SearchView.OnSuggestionListener {

	/** Called when the activity is first created. */
	private int mOptionMenu;
	private String mTitle;
	private boolean isEdit = false;
	private int mOptionSend = 0;
	private boolean isCustomBar = false;

	private TextView lblTitle;
	private TextView lblAction;
	private boolean isShowDeleteLK;
	private SearchView searchView;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// Check if no view has focus:

		final Intent intent = getIntent();
		mTitle = intent.getStringExtra(Utils.TITLE);
		mOptionMenu = intent.getIntExtra(Utils.KEY, 0);
		isCustomBar = intent.getBooleanExtra(Utils.CUSTOMBAR, false);
		if (isCustomBar) {
			getSupportActionBar()
					.setDisplayOptions(
							ActionBar.DISPLAY_SHOW_CUSTOM
									| ActionBar.DISPLAY_SHOW_HOME);
			getSupportActionBar().setCustomView(R.layout.taskbar_update_data);
			lblTitle = (TextView) findViewById(R.id.title);
			lblAction = (TextView) findViewById(R.id.lblCapnhat);
			lblTitle.setText(mTitle);
		}

		hideKeyboard();
		setContentView(R.layout.detailt_activity);
		getSupportActionBar().setIcon(R.drawable.ic_back);
		getSupportActionBar().setTitle(mTitle);
		getSupportActionBar().setDisplayShowHomeEnabled(true);
		getSupportActionBar().setHomeButtonEnabled(true);

		switch (mOptionMenu) {
		case R.id.add_family_medical:
			final boolean isUpdate1 = intent.getBooleanExtra(Utils.KEY_UPDATE,
					false);
			getSupportFragmentManager()
					.beginTransaction()
					.replace(
							R.id.fragment_detailt_container,
							FragmentClinicAddFamilyMedicalHistory
									.newInstance(isUpdate1), Utils.TAG_CHILD)
					.addToBackStack(null).commit();
			if (isUpdate1) {
				lblAction.setText(getResources().getString(R.string.cap_nhat));
			} else {
				lblAction.setText(getResources().getString(R.string.them));
			}
			lblAction.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					FragmentClinicAddFamilyMedicalHistory
							.newInstance(isUpdate1).onPostBienhien(isUpdate1);
				}
			});
			break;
		case Utils.PATIENT_DETAILT:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicPatientDetailt.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.them_lich_su_kham:
			final boolean isUpdate2 = intent.getBooleanExtra(Utils.KEY_UPDATE,
					false);
			getSupportFragmentManager()
					.beginTransaction()
					.replace(
							R.id.fragment_detailt_container,
							FragmentClinicAddListMedicalHistory
									.newInstance(isUpdate2), Utils.TAG_CHILD)
					.addToBackStack(null).commit();
			if (isUpdate2) {
				lblAction.setText(getResources().getString(R.string.cap_nhat));
			} else {
				lblAction.setText(getResources().getString(R.string.them));
			}
			lblAction.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					FragmentClinicAddListMedicalHistory.newInstance(isUpdate2)
							.onPostBienhien(isUpdate2);
				}
			});
			break;
		case R.id.them_ghi_chu:
			final boolean isUpdate3 = intent.getBooleanExtra(Utils.KEY_UPDATE,
					false);
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicAddNote.newInstance(isUpdate3),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			if (isUpdate3) {
				lblAction.setText(getResources().getString(R.string.cap_nhat));
			} else {
				lblAction.setText(getResources().getString(R.string.them));
			}
			lblAction.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					FragmentClinicAddNote.newInstance(isUpdate3)
							.onPostBienhien(isUpdate3);
				}
			});
			break;

		case R.id.ghi_chu:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicListNote.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			break;

		case R.id.lich_hen_kham:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicListAppoitMent.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.tin_nhan_doctor:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicMessages.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.lich_hen_doctor:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicLichhen.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.benh_nhan_doctor:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicListPatients.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.lich_su_kham_chua_benh:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicListMedicalHistory.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.lich_su_benh_cua_gia_dinh:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicFamilyMedicalHistory.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;
		case R.id.hinh_anh:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicImagesPatients.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			break;

		case R.id.cac_van_de_suc_khoe:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicBieuhien.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			break;
		case R.id.them_bieu_hien:
			final boolean isUpdate = intent.getBooleanExtra(Utils.KEY_UPDATE,
					false);
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicAddBieuHien.newInstance(isUpdate),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			if (isUpdate) {
				lblAction.setText(getResources().getString(R.string.cap_nhat));
			} else {
				lblAction.setText(getResources().getString(R.string.them));
			}
			lblAction.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					FragmentClinicAddBieuHien.newInstance(isUpdate)
							.onPostBienhien(isUpdate);
				}
			});
			break;
		case Utils.ADD_PATIENT:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.fragment_detailt_container,
							FragmentClinicAddPatients.newInstance(),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			lblAction.setText(getResources().getString(R.string.them));
			lblAction.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					FragmentClinicAddPatients.newInstance().pustData();
				}
			});
			break;

		case Utils.VIEW_IMG_PATIENT:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(
							R.id.fragment_detailt_container,
							FragmentClinicImagePagerPatients
									.newInstance(FragmentClinicImagesPatients
											.newInstance().getmPosition()),
							Utils.TAG_CHILD).addToBackStack(null).commit();
			break;

		case Utils.SEARCH_LICH_HEN_DOCTOR:
			getSupportFragmentManager()
					.beginTransaction()
					.replace(
							R.id.fragment_detailt_container,
							FragmentClinicResultSearch.newInstance(intent
									.getStringExtra(Utils.KEY_SEARCH)),
							Utils.TAG_CHILD).addToBackStack(null).commit();

			break;

		}

	}

	public void pickFile(int requestCode) {
		Intent intent = new Intent(Intent.ACTION_PICK);
		intent.setType("image/*");
		startActivityForResult(intent, requestCode);
	}

	public static String getRealPathFromURI(Context context, Uri contentURI) {
		if ("file".equalsIgnoreCase(contentURI.getScheme())) {
			return contentURI.getPath();
		}
		String result = "";
		String[] projection = { "_data" };
		Cursor cursor = context.getContentResolver().query(contentURI,
				projection, null, null, null);
		if (cursor == null) { // Source is Dropbox or other similar local file
								// path
			result = contentURI.getPath();
		} else if (cursor.moveToFirst()) {
			int idx = cursor.getColumnIndex("_data");
			result = cursor.getString(idx);
			cursor.close();
		}
		return result;
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (data == null)
			return;
		switch (requestCode) {
		case Utils.ADD_NOTE:
			FragmentClinicListNote.newInstance().onLoadData();
			break;
		case Utils.SELECT_PHONE_CONTACT_ADD_PATIENT:
			FragmentClinicAddPatients.newInstance().setPhone(
					Utils.getContactPhone(data, PatientActivity.this));
			break;
		case Utils.RESUME_PRICE:
			FragmentBangGia.newInstance().onLoadData();
			break;
		case Utils.THEM_LICH_SU_KHAM:
			FragmentClinicListMedicalHistory.newInstance().onLoadData();
			break;
		case Utils.ADD_FAMILY_MEDICAL_HIS:
			FragmentClinicFamilyMedicalHistory.newInstance().onLoadData();
			break;
		case Utils.ONRESUME_BIEU_HIEN:
			FragmentClinicBieuhien.newInstance().onLoadData();
			break;

		case Utils.ADD_IMAGES_PATIENTS:
			FragmentClinicImagesPatients.newInstance().updateInfo(data);
			break;

		case Utils.SELECT_PHONE_CONTACT:
			FragmentBookAppointment.newInstance(null).setPhone(
					Utils.getContactPhone(data, PatientActivity.this));
			break;
		case Utils.REQ_EDIT_AVATAR:
			FragmentAccount.newInstance().updateInfo(data);
			break;
		case Utils.REQ_UPLOADIMG:
			FragmentImages.newInstance().updateInfo(data);
			break;
		}

	}

	private void hideKeyboard() {
		// Check if no view has focus:
		View view = this.getCurrentFocus();
		if (view != null) {
			InputMethodManager inputManager = (InputMethodManager) this
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			inputManager.hideSoftInputFromWindow(view.getWindowToken(),
					InputMethodManager.HIDE_NOT_ALWAYS);
		}
	}

	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		Bundle bundle = new Bundle();
		switch (item.getItemId()) {

		case android.R.id.home:
			finish();
			break;
		case R.id.them_hinh_anh:
			pickFile(Utils.ADD_IMAGES_PATIENTS);
			break;
		case R.id.them_ghi_chu:
			bundle.putInt(Utils.KEY, R.id.them_ghi_chu);
			bundle.putString(Utils.TITLE,
					getResources().getString(R.string.the_ghi_chu));
			bundle.putBoolean(Utils.CUSTOMBAR, true);
			bundle.putInt(Utils.REQUEST_CODE, Utils.ADD_NOTE);

			Utils.getNewIntentToPatient(PatientActivity.this, bundle);
			break;
		case R.id.add_family_medical:
			bundle.putInt(Utils.KEY, R.id.add_family_medical);
			bundle.putString(Utils.TITLE,
					getResources().getString(R.string.lich_su_benh_cua_gd));
			bundle.putBoolean(Utils.CUSTOMBAR, true);
			bundle.putInt(Utils.REQUEST_CODE, Utils.ADD_FAMILY_MEDICAL_HIS);

			Utils.getNewIntentToPatient(PatientActivity.this, bundle);
			break;
		case R.id.them_lich_su_kham:
			bundle.putInt(Utils.KEY, R.id.them_lich_su_kham);
			bundle.putString(Utils.TITLE,
					getResources().getString(R.string.them_lich_kham));
			bundle.putBoolean(Utils.CUSTOMBAR, true);
			bundle.putInt(Utils.REQUEST_CODE, Utils.THEM_LICH_SU_KHAM);

			Utils.getNewIntentToPatient(PatientActivity.this, bundle);
			break;
		case R.id.cac_van_de_suc_khoe:
			bundle.putInt(Utils.KEY, R.id.them_bieu_hien);
			bundle.putString(Utils.TITLE,
					getResources().getString(R.string.them_bieu_hien));
			bundle.putBoolean(Utils.CUSTOMBAR, true);
			bundle.putInt(Utils.REQUEST_CODE, Utils.ONRESUME_BIEU_HIEN);
			Utils.getNewIntentToPatient(PatientActivity.this, bundle);
			break;

		case R.id.quang_li_hinh_anh:
			pickFile(Utils.REQ_UPLOADIMG);
			break;

		}
		return super.onMenuItemSelected(featureId, item);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		switch (mOptionMenu) {
		case R.id.dia_diem_kham:
			menu.add(0, R.id.dia_diem_kham, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			menu.add(0, R.id.edit_location_address, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_edit)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.hinh_anh:
			menu.add(0, R.id.them_hinh_anh, Menu.NONE,
					getResources().getString(R.string.them))
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;

		case R.id.ghi_chu:
			menu.add(0, R.id.them_ghi_chu, Menu.NONE,
					getResources().getString(R.string.them))
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;

		case R.id.tin_nhan_doctor:
			searchView = new SearchView(getSupportActionBar()
					.getThemedContext());
			searchView.setQueryHint("Tên bệnh nhân");
			searchView.setOnQueryTextListener(this);
			searchView.setOnSuggestionListener(this);

			menu.add(0, R.id.send_message_doctor, Menu.NONE,
					getResources().getString(R.string.them))
					.setIcon(R.drawable.ic_send_messages)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

			menu.add(1, Utils.SEARCH_LICH_HEN, Menu.NONE, "Tìm kiếm")
					.setIcon(R.drawable.ic_search)
					.setActionView(searchView)
					.setShowAsAction(
							MenuItem.SHOW_AS_ACTION_IF_ROOM
									| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
			setStyleSearch();

			break;

		case R.id.lich_hen_doctor:

			searchView = new SearchView(getSupportActionBar()
					.getThemedContext());
			searchView.setQueryHint("Tên bệnh nhân hoặc mã cuộc hẹn");
			searchView.setOnQueryTextListener(this);
			searchView.setOnSuggestionListener(this);
			menu.add(1, Utils.SEARCH_LICH_HEN, Menu.NONE, "Tìm kiếm")
					.setIcon(R.drawable.ic_search)
					.setActionView(searchView)
					.setShowAsAction(
							MenuItem.SHOW_AS_ACTION_IF_ROOM
									| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
			setStyleSearch();
			break;
		case R.id.lich_kham_doctor:
			menu.add(0, R.id.tao_lich_kham_doctor, Menu.NONE,
					getResources().getString(R.string.them))
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			menu.add(0, R.id.delete_lich_kham, Menu.NONE, "Tạo lịch hẹn")
					.setIcon(R.drawable.ic_edit)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

			break;
		case R.id.lich_su_kham_chua_benh:
			menu.add(0, R.id.them_lich_su_kham, Menu.NONE,
					getResources().getString(R.string.them))
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.lich_su_benh_cua_gia_dinh:
			menu.add(0, R.id.add_family_medical, Menu.NONE,
					getResources().getString(R.string.them))
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.reply_message:
			menu.add(0, R.id.attach_file_reply, Menu.NONE,
					getResources().getString(R.string.dinh_kem))
					.setIcon(R.drawable.ic_add_tattack)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.reply_message_doctor:
			menu.add(0, R.id.attach_file_reply_doctor, Menu.NONE,
					getResources().getString(R.string.dinh_kem))
					.setIcon(R.drawable.ic_add_tattack)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.send_message_doctor:
			menu.add(0, R.id.attach_file_sendmessage_doctor, Menu.NONE,
					getResources().getString(R.string.dinh_kem))
					.setIcon(R.drawable.ic_add_tattack)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.send_message:
			menu.add(0, R.id.attach_file_sendmessage, Menu.NONE,
					getResources().getString(R.string.dinh_kem))
					.setIcon(R.drawable.ic_add_tattack)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.message_detailt:
			// if (FragmentMessages.newInstance().getCurrentNotification()
			// .getReply_for_notification_id() >= 0) {
			if (mOptionSend == Utils.REPLY_PATIENT) {
				menu.add(0, R.id.reply_message, Menu.NONE, mTitle)
						.setIcon(R.drawable.ic_send_holo_light)
						.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			} else if (mOptionSend == Utils.REPLY_PATIENT_DOCTOR) {
				menu.add(0, R.id.reply_message_doctor, Menu.NONE, mTitle)
						.setIcon(R.drawable.ic_send_holo_light)
						.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			}
			// }
			break;
		case R.id.quan_ly_bacsi:
			menu.add(0, R.id.them_bac_si, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.cac_van_de_suc_khoe:
			menu.add(0, R.id.cac_van_de_suc_khoe, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.quan_ly_tro_ly:
			menu.add(0, R.id.them_tro_ly, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.bang_gia:

			menu.add(0, R.id.bang_gia, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			menu.add(0, R.id.edit_location_price, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_edit)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		case R.id.quang_li_hinh_anh:
			menu.add(0, R.id.quang_li_hinh_anh, Menu.NONE, mTitle)
					.setIcon(R.drawable.ic_add)
					.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
			break;
		default:
			break;
		}

		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public void onBackPressed() {
		finish();
	}

	@Override
	public void onDisplay(int type, Bundle data) {
		mOptionSend = data.getInt(Utils.KEY);
		invalidateOptionsMenu();
	}

	public void setStyleSearch() {
		AutoCompleteTextView searchText = (AutoCompleteTextView) searchView
				.findViewById(R.id.abs__search_src_text);
		searchText.setHintTextColor(getResources().getColor(
				android.R.color.white));
		searchText.setTextColor(getResources().getColor(android.R.color.white));
		searchText.setTextSize(14);
	}

	@Override
	public boolean onSuggestionSelect(int position) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onSuggestionClick(int position) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onQueryTextSubmit(String query) {
		if (query.isEmpty())
			return false;
		Bundle bundle = new Bundle();
		bundle.putBoolean(Utils.CUSTOMBAR, false);
		bundle.putString(Utils.TITLE, "Tìm kiếm '" + query + "'");
		bundle.putString(Utils.KEY_SEARCH, query);

		if (mOptionMenu == R.id.lich_hen_doctor) {
			bundle.putInt(Utils.KEY, Utils.SEARCH_LICH_HEN_DOCTOR);
			Utils.getNewIntent(PatientActivity.this, bundle);
		} else if (mOptionMenu == R.id.benh_nhan_doctor) {
			bundle.putInt(Utils.KEY, Utils.SEARCH_BENH_NHAN_DOCTOR);
			Utils.getNewIntent(PatientActivity.this, bundle);
		} else {
			bundle.putInt(Utils.KEY, Utils.SEARCH_MESSAGE_DOCTOR);
			Utils.getNewIntent(PatientActivity.this, bundle);
		}

		return false;
	}

	@Override
	public boolean onQueryTextChange(String newText) {
		// TODO Auto-generated method stub
		return false;
	}

}
